package io.renren.modules.region.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.modules.region.entity.TCountryEntity;
import io.renren.modules.region.entity.vo.CountryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 区域村庄
 *
 * @author lhb
 * @date 2023-05-24 11:51:23
 */
@Mapper
public interface TCountryDao extends BaseMapper<TCountryEntity> {

    //    @Select("SELECT td.*, tu.username as creatorName FROM t_device td LEFT JOIN tb_user tu ON td.creator = tu.user_id WHERE td.`status` = 1")
    @Select("SELECT tc.*, su.username as contract_name, su.mobile as contract_mobile FROM t_country tc LEFT JOIN sys_user su ON tc.contract = su.user_id ")
    List<CountryVO> queryCountries();

    @Select("SELECT tc.*, su.username as contract_name, su.mobile as contract_mobile FROM t_country tc LEFT JOIN sys_user su ON tc.contract = su.user_id WHERE tc.`name` LIKE #{key} OR su.`mobile` LIKE #{key}")
    List<CountryVO> queryDevicesByKeySearch(@Param("key") String key);
}
